<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>按钮 - view</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../dist/layui.css">
    <link rel="stylesheet" href="../jquery-plugin/contextMenu/jquery.contextMenu.css">
    <style>
        body {
            padding: 10px;
        }
    </style>
</head>
<body>

<span class="context-menu-one btn btn-neutral context-menu-disabled">right click me</span>

<button type="button btn btn-neutral" id="toggle-disabled">Enable Menu</button>

<script src="../dist/layui.js"></script>
<script>
    layui.use(['jquery', 'contextMenu'], function($, context){
        context.render({
            selector: '.context-menu-one',
            callback: function(key, options) {
                var m = "clicked: " + key;
                window.console && console.log(m) || alert(m);
            },
            items: {
                "edit": {name: "Edit", icon: "edit"},
                "cut": {name: "Cut", icon: "cut"},
                "copy": {name: "Copy", icon: "copy"},
                "paste": {name: "Paste", icon: "paste"},
                "delete": {name: "Delete", icon: "delete"},
                "sep1": "---------",
                "quit": {name: "Quit", icon: function($element, key, item){ return 'context-menu-icon context-menu-icon-quit'; }}
            }
        });

        $('#toggle-disabled').on('click', function(e) {
            e.preventDefault();
            var $this = $(this),
                $trigger = $('.context-menu-one');
            if ($trigger.hasClass('context-menu-disabled')) {
                $this.text("Disable Menu");
                $trigger.contextMenu(true);
            } else {
                $this.text("Enable Menu");
                $trigger.contextMenu(false);
            }
        });
    });
</script>
</body>
</html>
